authApp.controller("loginController",function($scope,$http,$cookieStore,$cookies){
	$scope.cancellogin=function(){
		var random=Math.random();
		location.href=paths.projectHome+"?random="+random;
	}
	$scope.login=function(){
		if(!$scope.user){
			alert("请填写用户名");
			return
		}
		if(!$scope.password){
			alert("请填写密码");
			return
		}
		if($scope.user!=""&&$scope.password!=""){
			$http({
				method:'post',
				url:apis.materialLogin,
				data:{'account':$scope.user,'password':$scope.password}
			}).success(function(response){
				var radom=Math.random();
				if(response.code=="000000"){
					$cookies.put('account',$scope.user,{"path":"/"});
					$cookies.put('accounttype','0',{"path":"/"});
					$cookies.put('employerName',response.data.expertName,{"path":"/"});
					$cookies.put('materialPid',response.data.userId,{"path":"/"});
					$cookies.put('identity',response.data.identity,{"path":"/"});
					location.href=paths.materialHome+"?radom="+radom;
				}else{
					alert(response.errorMsg);
				}
			}).error(function(){
				alert("服务器打瞌睡了，请稍等！");
			})
		}
	}
})